#!/bin/sh

#编译 software

#COMPILE_GCC=gcc
COMPILE_GCC=gcc


if [ $1 = "arm" ];then
	COMPILE_GCC=arm-hisiv100-linux-uclibcgnueabi
fi



printf   "\033[33m===============================================\n"
echo	 "Start compile software..................."
printf   "===============================================\n\033[0m"

rm -rf src/knda
rm -rf src/daemon
rm -fr src/2avi

make clean
aclocal
autoconf
automake -a
CXXFLAGS="-g -Wall" ./configure --host=$COMPILE_GCC


make


rm -rf ../bin/release/knda
rm -rf ../bin/release/daemon
rm -rf ../bin/release/da.xml
if [ $2 = "release" ];then	
	cp src/knda   ../bin/release/
	cp src/da.xml ../bin/release/
	$COMPILE_GCC-strip ../bin/release/knda
	$COMPILE_GCC-g++ -o src/daemon src/daemon.cpp src/daemon_log.c
	$COMPILE_GCC-gcc -o src/2avi src/avc2avi.c 
	$COMPILE_GCC-strip src/2avi
	$COMPILE_GCC-strip src/daemon
	cp src/daemon ../bin/release/
	cp src/2avi ../bin/release/	
	chmod +x src/upx
	src/upx ../bin/release/knda
	$COMPILE_GCC-strip ../bin/release/daemon
fi


